'''
Created on Jun 13, 2012

@author: thomas_dao
'''

from google.appengine.ext import ndb
from entity.entity import EventInvite

@ndb.tasklet
def count_by_event(event_key, **q_options):
    qry = EventInvite.query(EventInvite.event == event_key)
    count = yield qry.count_async(**q_options)
    raise ndb.Return(count)

@ndb.tasklet
def count_by_event_list(event_key_list, **q_options):
    counts = []
    for event_key in event_key_list:
        count = yield count_by_event(event_key, **q_options)
        counts.append(count)
                
    raise ndb.Return(counts)